package com.jy.adscm.declarationForm.controller;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.annotation.AdscmLogger;
import com.jy.adscm.bean.JwdEntity;
import com.jy.adscm.bean.system.JyCode;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.dealer.bean.Dealer;
import com.jy.adscm.dealer.service.DealerService;
import com.jy.adscm.declarationForm.bean.JyDeclarationForm;
import com.jy.adscm.declarationForm.bean.JyFormTermManage;
import com.jy.adscm.declarationForm.service.JyDeclarationFormService;
import com.jy.adscm.declarationForm.service.JyFormTermManageService;
import com.jy.adscm.declarationForm.support.DeclarationFormSupport;
import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.hospital.bean.JyHospitalBase;
import com.jy.adscm.hospital.service.JyHospitalBaseService;
import com.jy.adscm.security.utils.Token;
import com.jy.adscm.support.SimpleCoreResponse;
import com.jy.adscm.system.mapper.mysql.JyCodeMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * <p>
 * 报单审核
 * </p>
 *
 * @author yyy
 * @since 2019-01-21
 */
@RestController
@RequestMapping("/adscm/dealer/jyDeclarationFormAudit")
public class JyDeclarationFormAuditController {


    @Autowired
    JyDeclarationFormService jyDeclarationFormService;
    @Autowired
    DealerService dealerService;
    @Autowired
    RedisTemplate<Object, Token> tokenRedisTemplate;
    @Autowired
    JyHospitalBaseService jyHospitalBaseService;
    @Autowired
    JyFormTermManageService jyFormTermManageService;
    @Autowired
    JyCodeMapper jyCodeMapper;

    /**
     * 查询当前登录用户自己管理的经销商的申请列表
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/querySelfDeclarationForm")
    @AdscmLogger("查询当前登录用户自己管理的经销商的申请列表")
    public SimpleCoreResponse querySelfDeclarationForm( HttpServletRequest request) throws AdscmSystemException {

        String tokenId = request.getParameter("tokenId");
        JyUser user = AdscmBaseUtils.getInstance().getUser(tokenId, tokenRedisTemplate);

        List<JyDeclarationForm> formList = null;

        Wrapper<Dealer> wrapper = new EntityWrapper<>();
        wrapper.eq("jy_manager",user.getId());
        List<Dealer> dealers = dealerService.selectList(wrapper);

        if (dealers != null && dealers.size()>0){
            List<Integer> list = new ArrayList<>();
            for (Dealer dealer : dealers) {
                list.add(dealer.getId());
            }
            formList = jyDeclarationFormService.queryApplyByDealerId(list,0);
        }


        return new SimpleCoreResponse("200","查询当前登录用户自己管理的经销商的申请列表成功",formList);
    }
    /**
     * 查询当前登录用户自己管理的经销商的报单意向列表
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/querySelfDecFormYix")
    @AdscmLogger("查询当前登录用户自己管理的经销商的报单意向列表")
    public SimpleCoreResponse querySelfDecFormYix( HttpServletRequest request) throws AdscmSystemException {

        String tokenId = request.getParameter("tokenId");
        JyUser user = AdscmBaseUtils.getInstance().getUser(tokenId, tokenRedisTemplate);

        List<JyDeclarationForm> formList = null;

        Wrapper<Dealer> wrapper = new EntityWrapper<>();
        wrapper.eq("jy_manager",user.getId());
        List<Dealer> dealers = dealerService.selectList(wrapper);

        if (dealers != null && dealers.size()>0){
            List<Integer> list = new ArrayList<>();
            for (Dealer dealer : dealers) {
                list.add(dealer.getId());
            }
            formList = jyDeclarationFormService.queryApplyByDealerId(list,1);
        }
        if (formList == null){
            formList = new ArrayList<>();
        }

        return new SimpleCoreResponse("200","查询当前登录用户自己管理的经销商的申请列表成功",formList);
    }
    /**
     * 查询所有报单记录
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/queryAllDecForm")
    @AdscmLogger("查询所有报单记录")
    public SimpleCoreResponse queryAllDecForm( HttpServletRequest request) throws AdscmSystemException {
        String tokenId = request.getParameter("tokenId");
        JyUser user = AdscmBaseUtils.getInstance().getUser(tokenId, tokenRedisTemplate);

        return new SimpleCoreResponse("200","查询所有报单记录成功",jyDeclarationFormService.selectAll(user));
    }
    /**
     * 根据医院ID，查询某个医院的报单详情
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/queryHospitalDeclarationFormDetail/{hospitalId}")
    @AdscmLogger("根据医院ID，查询某个医院的报单详情")
    public SimpleCoreResponse queryHospitalDeclarationFormDetail(@PathVariable Long hospitalId) throws AdscmSystemException {

        List<JyDeclarationForm> formList = null;
        if(hospitalId != null){
            Wrapper<JyDeclarationForm> wrapper = new EntityWrapper<>();
            wrapper.eq("apply_hospital_id",hospitalId);
            formList = jyDeclarationFormService.queryHospitalDeclarationFormDetail(hospitalId);
        }

        return new SimpleCoreResponse("200","查询成功",formList);
    }

    /**
     * 提交审核之前，先判断是否有其他经销商正在申请报单这个医院的这个科室
     * @param formId
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/queryAuditFormStatus/{formId}")
    @AdscmLogger("提交审核之前，先判断是否有其他经销商正在申请报单这个医院的这个科室")
    public SimpleCoreResponse queryAuditFormStatus(@PathVariable Long formId) throws AdscmSystemException {
        int result = this.getAuditResult(formId);
        if (result == 1){
            return new SimpleCoreResponse("300","当前医院的当前科室，有其他经销商也在报单，在等待厂商审核， 是否继续审核？" +
                    "<br/> （如果继续审核，其他经销商的报单申请在审核的时候将会直接加入意向队列！）",0);
        }else if(result == 2){
            return new SimpleCoreResponse("300","当前医院的当前科室已经被其他经销商报单成功了， 是否继续审核 ？" +
                    "<br/>（如果继续审核，此报单记录将不会审核通过，由系统直接转入意向队列中！）",4);
        }else {
            return new SimpleCoreResponse("200","可以报单",0);
        }

    }

    /**
     * 得到报单的审核结果，1 代表有其他经销商在报单当前医院的当前科室，但还未审核，2 表示有其他经销商在报单当前医院的当前科室，已经审核通过了
     * @param formId
     * @return
     * @throws AdscmSystemException
     */
    private int getAuditResult(Long formId)throws AdscmSystemException {
        int result = 0;
        if (formId != null && formId > 0){
            JyDeclarationForm form = jyDeclarationFormService.selectById(formId);
            if (form != null){
                Long applyHospitalId = form.getApplyHospitalId();//医院
                Long applyOffice = form.getApplyOffice();//科室
                if (applyHospitalId != null && applyOffice != null){
                    Wrapper<JyDeclarationForm> wrapper = new EntityWrapper<>();
                    wrapper.eq("apply_hospital_id",applyHospitalId);
                    wrapper.eq("apply_office",applyOffice);
                    wrapper.eq("apply_status",1);
                    int num = jyDeclarationFormService.selectCount(wrapper);

                    if (num > 0){
                        //有审核通过的了
                        result = 2;
                    }else {
                        wrapper.eq("apply_status",0);
                        num = jyDeclarationFormService.selectCount(wrapper);
                        if (num > 0){
                            //有正在审核的
                            result = 1;
                        }
                    }
                }else {
                    throw new AdscmSystemException("报单信息不全，不能审核！");
                }
            }else {
                throw new AdscmSystemException("参数获取失败，提交报单审核信息异常！");
            }

        }else {
            throw new AdscmSystemException("参数获取失败，提交报单审核信息异常！");
        }
        return result;
    }



    /**
     * 提交报单审核信息
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/submitAudit")
    @AdscmLogger("提交报单审核信息")
    public SimpleCoreResponse submitAudit(@RequestBody JyDeclarationForm jyDeclarationForm, HttpServletRequest request) throws AdscmSystemException {

        String tokenId = request.getParameter("tokenId");
        JyUser user = AdscmBaseUtils.getInstance().getUser(tokenId, tokenRedisTemplate);


        if (jyDeclarationForm != null){
            Long formId = jyDeclarationForm.getId();
            if (formId != null && formId > 0){
                int result = this.getAuditResult(formId);
                JyDeclarationForm form = jyDeclarationFormService.selectById(formId);
                form.setAuditDetail(jyDeclarationForm.getAuditDetail());
                form.setApplyStatus(jyDeclarationForm.getApplyStatus());
                jyDeclarationForm = form;

                if(result == 2){
                    jyDeclarationForm.setApplyStatus(4);
                    jyDeclarationFormService.updateById(jyDeclarationForm);
                    throw new AdscmSystemException("当前医院的当前科室已经被其他经销商报单成功了，审核失败，系统自动给您加入了意向列表！");
                }
            }

            if (user != null){
                jyDeclarationForm.setAuditUserId(user.getId());
            }
            jyDeclarationForm.setAuditTime(new Date());
            Integer applyStatus = jyDeclarationForm.getApplyStatus();
            if (applyStatus != null && applyStatus == 1){
                //证明审核通过了，然后就纳入报单的期限管控队列中
                Wrapper<JyFormTermManage> wrapper = new EntityWrapper<>();
                wrapper.eq("form_id",jyDeclarationForm.getId());
                JyFormTermManage jyFormTermManage = jyFormTermManageService.selectOne(wrapper);
                if (jyFormTermManage == null){
                    jyFormTermManage = new JyFormTermManage();
                    jyFormTermManage.setFormId(jyDeclarationForm.getId());
                }

                List<JyCode> formTerm = jyCodeMapper.getJyCodeByCodeType("declaration_form_term");
                if (formTerm != null && formTerm.size()>0){
                    JyCode jyCode = formTerm.get(0);
                    Integer totalTerm = 0;
                    try{
                        totalTerm = Integer.parseInt(jyCode.getCode());
                    }catch (Exception e){
                    }
                    jyFormTermManage.setTotalTerm(totalTerm);//总期限
                    jyFormTermManage.setSurplusTerm(totalTerm);//剩余期限
                }
                jyFormTermManage.setFormStatus(0);
                jyFormTermManage.setCreateDate(new Date());
                jyFormTermManageService.insertOrUpdate(jyFormTermManage);
            }

            JyDeclarationForm form = jyDeclarationFormService.selectById(jyDeclarationForm.getId());
            if (form.getApplyHospitalId() != null && form.getApplyHospitalId() > 0){
                jyDeclarationFormService.updateById(jyDeclarationForm);
            }else {
                throw new AdscmSystemException("请先确定医院信息，才能提交审核信息！");
            }
        }else {
            throw new AdscmSystemException("参数获取失败，提交报单审核信息异常！");
        }


        return new SimpleCoreResponse("200","审核成功",null);
    }


    /**
     * 在确定保存医院信息之前，先判断医院信息目前在数据库的状态，是否存在地址相同的医院，如果存在，则返回，并在保存医院信息的时候，带上这个医院的ID
     * @param jyDeclarationForm
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/getHospitalStatus")
    @AdscmLogger("在确定保存医院信息之前，先判断医院信息目前在数据库的状态，是否存在地址相同的医院")
    public SimpleCoreResponse getHospitalStatus(@RequestBody JyDeclarationForm jyDeclarationForm)throws AdscmSystemException {
        if (jyDeclarationForm != null){

            List<JyHospitalBase> bases = jyHospitalBaseService.queryAllHospitalBaseList();

            for (JyHospitalBase basis : bases) {
                float ratio = AdscmBaseUtils.getInstance().getSimilarityRatio(jyDeclarationForm.getApplyAddressSheng(), basis.getAddressSheng());
                if (ratio == 1.0){
                    ratio = AdscmBaseUtils.getInstance().getSimilarityRatio(jyDeclarationForm.getApplyAddressShi(), basis.getAddressShi());
                    if (ratio == 1.0){
                        ratio = AdscmBaseUtils.getInstance().getSimilarityRatio(jyDeclarationForm.getApplyAddressQuxian(), basis.getAddressQuxian());
                        if (ratio == 1.0){
                            ratio = AdscmBaseUtils.getInstance().getSimilarityRatio(jyDeclarationForm.getApplyAddressDetail(), basis.getAddressDetail());
                            if (ratio == 1.0){
                                //证明医院的地址完全符合
                                return new SimpleCoreResponse("300","系统中已经存在与当前报单医院地址完全一样的医院，医院名称为【"+basis.getHospitalName()+"】<br/>" +
                                        "是否合并？<br/>（合并后当前报单的医院就是系统中存在的那个医院！）",basis.getId());
                            }else if (ratio > 0.5){
                                //地理位置相近
                                String address = basis.getAddressSheng() +  basis.getAddressShi() +  basis.getAddressQuxian() + basis.getAddressDetail();
                                return new SimpleCoreResponse("301","系统中已经存在与当前报单医院地址相似度较高的医院，医院名称为【"+basis.getHospitalName()+"】<br/>" +
                                        "医院地址为【"+address+"】<br/>" +
                                        "请选择【合并】或【新增】操作：<br/>" +
                                        "（合并后当前报单的医院就是系统中存在的那个医院！）<br/>" +
                                        "（新增将会重新在系统中增加一个医院！）",basis.getId());
                            }
                        }
                    }
                }
            }
            return new SimpleCoreResponse("200","可以直接新增",null);

        }else {
            throw new AdscmSystemException("参数获取失败，提交医院信息异常！");
        }
    }

    /**
     * 确定保存医院信息
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/confirmSaveHospital")
    @AdscmLogger("确定保存医院信息")
    public SimpleCoreResponse confirmSaveHospital(@RequestBody JyDeclarationForm jyDeclarationForm, HttpServletRequest request) throws AdscmSystemException {

        if (jyDeclarationForm != null){


            if (jyDeclarationForm.getApplyHospitalId() != null && jyDeclarationForm.getApplyHospitalId() > 0){
                //证明是选择的医院，直接提交保存报单表
                jyDeclarationFormService.updateById(jyDeclarationForm);
            }else {
                //证明确实是新增的医院，就要先保存医院信息，然后再保存报单表
                JyHospitalBase hospitalBase = this.loadHospital(jyDeclarationForm);

                JyDeclarationForm form = jyDeclarationFormService.selectById(jyDeclarationForm.getId());
                hospitalBase.setInputUserId(form.getApplyDealerUserId());
                hospitalBase.setInputUnit(form.getApplyDealerId());
                hospitalBase.setInputUnitType(2);//经销商
                hospitalBase.setInputTime(form.getApplyTime());

                boolean flag = jyHospitalBaseService.insert(hospitalBase);
                if (flag){
                    jyDeclarationForm.setApplyHospitalId(hospitalBase.getId());
                    jyDeclarationFormService.updateById(jyDeclarationForm);
                }else {
                    throw new AdscmSystemException("提交医院信息异常，请联系系统管理员！");
                }
            }
        }else {
            throw new AdscmSystemException("参数获取失败，提交医院信息异常！");
        }

        return new SimpleCoreResponse("200","确定保存医院信息成功",jyDeclarationForm);
    }

    /**
     * 根据医院名称，模糊查询对应医院的报单列表
     * @param hospitalName 医院名称
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/queryAllJwdLikeHospitalName")
    @AdscmLogger("根据医院名称，模糊查询对应医院的报单列表对应的定位")
    public SimpleCoreResponse queryAllJwdLikeHospitalName(String hospitalName) throws AdscmSystemException {

        List<JyHospitalBase> jyHospitalBases = new ArrayList<>();
        hospitalName = AdscmBaseUtils.getInstance().addLikeStr(hospitalName);
        if (hospitalName != null && !"".equals(hospitalName)){
            Wrapper<JyDeclarationForm> wrapper = new EntityWrapper<>();
            wrapper.like("apply_hospital_name",hospitalName);
            List<JyDeclarationForm> list = jyDeclarationFormService.selectList(wrapper);
            Map<Long,Long> tempMap = new HashMap<>();
            if (list != null && list.size()>0){
                for (JyDeclarationForm form : list) {

                    Long applyHospitalId = form.getApplyHospitalId();
                    if (applyHospitalId != null && applyHospitalId >0){
                        //去重
                        if (tempMap.get(applyHospitalId) != null){
                            continue;
                        }else {
                            tempMap.put(applyHospitalId,applyHospitalId);
                        }

                        JyHospitalBase hospitalBase = jyHospitalBaseService.selectById(applyHospitalId);

                        //库中的正式医院
                        wrapper = new EntityWrapper<>();
                        wrapper.eq("apply_hospital_id",applyHospitalId);
                        wrapper.eq("apply_status",1);
                        int count = jyDeclarationFormService.selectCount(wrapper);
                        if (count > 0){
                            hospitalBase.setApplyStatus(1);
                        }else {
                            hospitalBase.setApplyStatus(0);
                        }

                        jyHospitalBases.add(hospitalBase);
                    }else {
                        //不是库中的正式医院，就直接获取经纬度
                        JyHospitalBase hospitalBase = this.loadHospital(form);

                        JwdEntity jwdByAddress = AdscmBaseUtils.getInstance().getJwdByAddress(hospitalBase.getAddressSheng() + hospitalBase.getAddressShi() + hospitalBase.getAddressQuxian() + hospitalBase.getAddressDetail());

                        if (jwdByAddress != null){
                            hospitalBase.setHospitalJd(jwdByAddress.getJd());
                            hospitalBase.setHospitalWd(jwdByAddress.getWd());
                        }
                        jyHospitalBases.add(hospitalBase);
                    }

                }
            }

        }

        return new SimpleCoreResponse("200","查询成功",jyHospitalBases);
    }
    /**
     * 获取所有医院的基本信息和定位、报单状态（传入当前报单的ID，获取当前报单医院的定位）
     * @param declarationFormId 报单ID
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/queryAllHospitalJwd/{declarationFormId}")
    @AdscmLogger("获取所有医院的基本信息和定位、报单状态（传入当前报单的ID，获取当前报单医院的定位）")
    public SimpleCoreResponse queryAllHospitalJwd(@PathVariable Long declarationFormId) throws AdscmSystemException {

//        JyDeclarationForm jyDeclarationForm = jyDeclarationFormService.selectById(declarationFormId);

//       return loadJwd(jyDeclarationForm);
       return loadJwd_1();
    }


    private SimpleCoreResponse loadJwd_1(){
        List<JyHospitalBase> jyHospitalBases = jyHospitalBaseService.queryAllHospitalBaseList();

        if (jyHospitalBases != null && jyHospitalBases.size()>0){
            for (int i=0;i<jyHospitalBases.size();i++) {
                JyHospitalBase hospitalBase = jyHospitalBases.get(i);
                Integer applyStatus = hospitalBase.getApplyStatus();
                if (applyStatus != null && applyStatus.intValue() != 2){

                    Long hospitalType = hospitalBase.getHospitalType();
                    if (hospitalType.intValue() == 4){
                        hospitalBase.setApplyStatus(1);
                    }else if (hospitalType.intValue() == 3){
                        hospitalBase.setApplyStatus(0);
                    }else if (hospitalType.intValue() == 2){
                        hospitalBase.setApplyStatus(3);
                    }

//                    //2. 判断医院的报单状态 0：未报单，1：已报单，2：当前报单医院
//                    Wrapper<JyDeclarationForm> wrapper = new EntityWrapper<>();
//                    wrapper.eq("apply_hospital_id",jyHospitalBases.get(i).getId());
//                    wrapper.eq("apply_status",1);
//                    int count = jyDeclarationFormService.selectCount(wrapper);
//                    if (count > 0){
//                        jyHospitalBases.get(i).setApplyStatus(1);
//                    }else {
//                        if("美容医院".equals(jyHospitalBases.get(i).getHospitalTypeDesc())){
//                            jyHospitalBases.get(i).setApplyStatus(3);
//                        }else {
//                            jyHospitalBases.get(i).setApplyStatus(0);
//                        }
//                    }
                }
            }
        }

        return new SimpleCoreResponse("200","查询成功",jyHospitalBases);
    }

    private SimpleCoreResponse loadJwd(JyDeclarationForm jyDeclarationForm){
        List<JyHospitalBase> jyHospitalBases = jyHospitalBaseService.queryAllHospitalBaseList();

//        List<DeclarationFormSupport> formSupports = this.changeFormClassType(jyHospitalBases);

        if (jyHospitalBases != null && jyHospitalBases.size()>0){

            Long applyHospitalId = null;
            if (jyDeclarationForm != null){
                applyHospitalId = jyDeclarationForm.getApplyHospitalId();
            }

            boolean flag = true;

            for (int i=0;i<jyHospitalBases.size();i++) {


                //循环判断每一个医院
                if (applyHospitalId != null && applyHospitalId > 0 && (jyHospitalBases.get(i).getId().longValue() == applyHospitalId.longValue())){
                    //1. 是当前医院
                    jyHospitalBases.get(i).setApplyStatus(2);
                    flag = false;
                }else {
                    //2. 判断医院的报单状态 0：未报单，1：已报单，2：当前报单医院
                    Wrapper<JyDeclarationForm> wrapper = new EntityWrapper<>();
                    wrapper.eq("apply_hospital_id",jyHospitalBases.get(i).getId());
                    wrapper.eq("apply_status",1);
                    int count = jyDeclarationFormService.selectCount(wrapper);
                    if (count > 0){
                        jyHospitalBases.get(i).setApplyStatus(1);
                    }else {
                        jyHospitalBases.get(i).setApplyStatus(0);
                    }
                }
            }

            if (flag){
                //不是存在的医院
                JyHospitalBase hospitalBase = this.loadHospital(jyDeclarationForm);
//                String jsonStr = JSONObject.toJSONString(hospitalBase);
//                DeclarationFormSupport support =  JSONObject.parseObject(jsonStr, DeclarationFormSupport.class);

                JwdEntity jwdByAddress = AdscmBaseUtils.getInstance().getJwdByAddress(hospitalBase.getAddressSheng() + hospitalBase.getAddressShi() + hospitalBase.getAddressQuxian() + hospitalBase.getAddressDetail());

                if (jwdByAddress != null){
                    hospitalBase.setHospitalJd(jwdByAddress.getJd());
                    hospitalBase.setHospitalWd(jwdByAddress.getWd());
                }
                hospitalBase.setApplyStatus(2);
                jyHospitalBases.add(hospitalBase);
            }



        }

        return new SimpleCoreResponse("200","查询成功",jyHospitalBases);
    }


    private List<DeclarationFormSupport> changeFormClassType( List<JyHospitalBase> jyHospitalBases){
        String jsonStr = JSONArray.toJSONString(jyHospitalBases);

        return JSONArray.parseArray(jsonStr, DeclarationFormSupport.class);
    }

    private JyHospitalBase loadHospital(JyDeclarationForm jyDeclarationForm){
        JyHospitalBase hospitalBase = new JyHospitalBase();
        hospitalBase.setHospitalName(jyDeclarationForm.getApplyHospitalName());
        hospitalBase.setHospitalType(jyDeclarationForm.getApplyHospitalType());
        hospitalBase.setHospitalLevel(jyDeclarationForm.getApplyHospitalLevel());
        hospitalBase.setAddressSheng(jyDeclarationForm.getApplyAddressSheng());
        hospitalBase.setAddressShi(jyDeclarationForm.getApplyAddressShi());
        hospitalBase.setAddressQuxian(jyDeclarationForm.getApplyAddressQuxian());
        hospitalBase.setAddressDetail(jyDeclarationForm.getApplyAddressDetail());
        hospitalBase.setApplyStatus(jyDeclarationForm.getApplyStatus());
        return hospitalBase;
    }
}
